#include <Bounce.h>


const int player1_Hole1 = 52;
const int player1_Hole2 = 50;
const int player1_Hole3 = 48;
const int player2_Hole1 = 31;
const int player2_Hole2 = 33;
const int player2_Hole3 = 35;
int p1_score = 0; // Player 1 score
int p2_score = 0; // Player 2 score
Bounce player1Hole1 = Bounce(player1_Hole1, 100);
Bounce player1Hole2 = Bounce(player1_Hole2, 100);
Bounce player1Hole3 = Bounce(player1_Hole3, 100);
Bounce player2Hole1 = Bounce(player2_Hole1, 100);
Bounce player2Hole2 = Bounce(player2_Hole2, 100);
Bounce player2Hole3 = Bounce(player2_Hole3, 100);      

void setup() {
  Serial.begin(9600);
  // Initialize inputs
  pinMode(player1_Hole1, INPUT);
  pinMode(player1_Hole2, INPUT);
  pinMode(player1_Hole3, INPUT);
  pinMode(player2_Hole1, INPUT);
  pinMode(player2_Hole2, INPUT);
  pinMode(player2_Hole3, INPUT);
  pinMode(13, OUTPUT);
      
}

void loop(){
  p1_score=0; // Reset score flag
  p2_score=0;
  player1Hole1.update();
  if (player1Hole1.read() == HIGH) { p1_score = 1; }
    player1Hole2.update();
  if (player1Hole2.read() == HIGH) { p1_score = 3; }
    player1Hole3.update();
  if (player1Hole3.read() == HIGH) { p1_score = 9; }
    player2Hole1.update();
  if (player2Hole1.read() == HIGH) { p2_score = 1; }
    player2Hole2.update();
  if (player2Hole2.read() == HIGH) { p2_score = 3; }
    player2Hole3.update();
  if (player2Hole3.read() == HIGH) { p2_score = 9; }
  
  if ((p1_score != 0) || (p2_score != 0)) { // Player scored
    
    Serial.print("P1:");
    Serial.println(p1_score);
    Serial.print("P2:");
    Serial.println(p2_score);
  }  
  delay(100);
}


